<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
    <meta charset="utf-8" />
    <title>激活码生成</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <link href="http://tv.speechb.com/lib/layui/css/layui.css" rel="stylesheet"/>
</head>
<body >
<!--
<script id="editor" type="text/plain" style="height: 150px;"/>

-->
<!-- Main content -->
<div style="margin-top: 30px;margin-right: 22px">
    <div class="layui-form" action="" style="max-width: 640px;margin: 0 auto">
    <div class="layui-form-item">
        <label class="layui-form-label">原密码</label>
        <div class="layui-input-block">
            <input type="password" name="origin_password" required  lay-verify="required" placeholder="请输入当前密码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-block">
            <input type="password" name="new_password" required  lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">验证码</label>
        <div class="layui-input-inline">
            <input type="text" name="captcha" required lay-verify="required" placeholder="请输入校验码"  class="layui-input">
        </div>
        <div id="captcha_div" class="layui-form-mid layui-word-aux"><img id="captcha_img" src="/image/captcha?type=admin_change_password"/></div>
    </div>

    <div class="layui-form-item" style="text-align: center;">
        <div class="layui-input-block">
            <button id="submitBtn" class="layui-btn" lay-submit lay-filter="formDemo" style="margin: 0 auto">立即提交
            </button>
        </div>
    </div>
    </div>
</div>
</div>
<script type="text/javascript" charset="utf-8" src="http://tv.speechb.com/lib/layui/layui.js"></script>
<script src="http://tv.speechb.com/lib/superui/content/ui/global/jQuery/jquery.min.js"></script>
<script type="text/javascript">

    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $.ajax({
                type : "PUT",
                url : "/admin/sys_user/change_pwd",
                data: {
                    "origin_password": data.field.origin_password,
                    "new_password": data.field.new_password,
                    "captcha":data.field.captcha
                },
                success : function(result) {
                    $("#activation_code").html("");
                    var activationCode = $("#activation_code");
                    if(result.code==1) {
                        layer.msg('更改密码成功！', {icon: 1});
                    } else {
                        layer.msg('更改密码失败！', {icon: 5});
                    }
                    $("#captcha_img").attr("src", "/image/captcha?type=admin_change_password&date="+new Date().getTime());
                },
                error : function(e){
                    layer.msg('请求异常！', {icon: 5});
                    $("#captcha_img").attr("src", "/image/captcha?type=admin_change_password&date="+new Date().getTime());
                }
            });
            return false;
        });
    });
    $(function(){

        $("#captcha_div").click(function () {
            $("#captcha_img").attr("src", "/image/captcha?type=admin_change_password&date="+new Date().getTime());
        });
    });

</script>
</body>

</html>